import { loadPlugin, loadPluginFn } from '../../app/config/loadplugin.config.js';
import authService from '../../app/resolves/authService.js';
import getCpList from '../../cp/resolves/getCpList.js';
import getCourseList from '../../course/resolves/getCourseList.js';
import getRealtimeRunner from '../resolves/getRealtimeRunner.js';
import getRealtimeTeam from '../resolves/getRealtimeTeam.js';
import getGroupList from '../../runner/resolves/getGroupList.js';
import getRaceDetail from '../../race/resolves/getRaceDetail.js';

import scoreListHtml from 'ngtemplate!html!../../../tpls/score/score.list.html';
import realtimeRunnerHtml from 'ngtemplate!html!../../../tpls/realtime/realtime.runner.html';
import realtimeListHtml from 'ngtemplate!html!../../../tpls/realtime/realtime.list.html';
import realtimeTeamHtml from 'ngtemplate!html!../../../tpls/realtime/realtime.team.html';
import rawdataHtml from 'ngtemplate!html!../../../tpls/score/rawdata.html';
import rawdataListHtml from 'ngtemplate!html!../../../tpls/score/rawdata.list.html';
//个人实时成绩查询
import realtimeListPersonalHtml from  'ngtemplate!html!../../../tpls/realtime/realtime.list.personal.html';
import realtimeListTeamHtml from 'ngtemplate!html!../../../tpls/realtime/realtime.list.team.html'


/**
 * ScoreRouter - config
 * 赛事模块路由设置
 */
ScoreRouter.$inject = ['$stateProvider', '$urlRouterProvider', '$httpProvider', '$locationProvider', '$ocLazyLoadProvider'];
function ScoreRouter($stateProvider, $urlRouterProvider, $httpProvider, $locationProvider, $ocLazyLoadProvider) {
	
	//set router
    $stateProvider

		// 选手成绩列表
		.state('dashboard.race.scorelist', {
		    url: '/score/list',
		    data: { 
		        pageTitle: '选手成绩列表' 
		    },
		    templateUrl: scoreListHtml,
		    controller: 'ScoreListController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList,
	            loadPlugin: loadPluginFn(loadPlugin.dataTables)
	        }
		})

		// 实时成绩查询
		.state('dashboard.race.realtimelist', {
		    url: '/realtime/list',
		    data: { 
		        pageTitle: '实时成绩查询' 
		    },
		    templateUrl: realtimeListHtml,
		    controller: 'RealtimeListController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList,
		    	loadPlugin: loadPluginFn(loadPlugin.dataTables),
		    	loadPlugin2: loadPluginFn(loadPlugin.blink)
	        }
		})

		// 个人实时成绩查询(新)
		.state('dashboard.race.realtimelistpersonal', {
		    url: '/realtime/list/personal?back',
		    data: { 
		        pageTitle: '个人实时成绩查询' 
		    },
		    templateUrl: realtimeListPersonalHtml,
		    controller: 'RealtimeListPersonalController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList,
		    	getGroupList: getGroupList,
		    	loadPlugin: loadPluginFn(loadPlugin.dataTables),
		    	loadPlugin2: loadPluginFn(loadPlugin.blink)
	        }
		})

		// 团队实时成绩查询(新)
		.state('dashboard.race.realtimelistteam', {
		    url: '/realtime/list/team',
		    data: { 
		        pageTitle: '个人实时成绩查询' 
		    },
		    templateUrl: realtimeListTeamHtml,
		    controller: 'RealtimeListTeamController as vm',
		    resolve: {
		    	authService: authService,
		    	getCourseList: getCourseList,
		    	getGroupList: getGroupList,
		    	loadPlugin: loadPluginFn(loadPlugin.dataTables),
		    	loadPlugin2: loadPluginFn(loadPlugin.blink)
	        }
		})

		// 团队详情
		.state('dashboard.race.realtimeteam', {
		    url: '/realtime/team?course_id&team_name',
		    data: { 
		        pageTitle: '团队详情' 
		    },
		    templateUrl: realtimeTeamHtml,
		    controller: 'RealtimeTeamController as vm',
		    resolve: {
		    	authService: authService,
		    	getRealtimeTeam: getRealtimeTeam
	        }
		})

		// 个人成绩
		.state('dashboard.race.realtimerunner', {
		    url: '/realtime/runner?course_id&runner_id',
		    data: { 
		        pageTitle: '个人成绩' 
		    },
		    templateUrl: realtimeRunnerHtml,
		    controller: 'RealtimeController as vm',
		    resolve: {
		    	authService: authService,
		    	getRealtimeRunner: getRealtimeRunner
	        }
		})

		// 原始数据管理
		.state('dashboard.race.rawdatalist', {
		    url: '/rawdata/list',
		    data: { 
		        pageTitle: '原始数据管理' 
		    },
		    templateUrl: rawdataListHtml,
		    controller: 'RawdataListController as vm',
		    resolve: {
		    	authService: authService,
	            loadPlugin: loadPluginFn(loadPlugin.dataTables)
	        }
		})

		// 补录选手数据
		.state('dashboard.race.rawdata', {
		    url: '/rawdata',
		    data: { 
		        pageTitle: '补录选手数据' 
		    },
		    templateUrl: rawdataHtml,
		    controller: 'RawdataController as vm',
		    resolve: {
		    	authService: authService,
		    	getCpList: getCpList,
		    	getRaceDetail: getRaceDetail,
		    	loadPlugin: loadPluginFn([loadPlugin.moment, loadPlugin.icheck, loadPlugin.blink])
	        }
		});
	

}

export default ScoreRouter;